﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LCL
{
    public static class StringBuilderExtensions
    {
        public static string Space(this StringBuilder str, int SpaceNum)
        {
            for (int i = 0; i < SpaceNum; i++)
            {
                str.Append("\t");
            }
            return str.ToString();
        }
        public static string DelLastComma(this StringBuilder str)
        {
            string text = str.ToString();
            int num = text.LastIndexOf(",");
            if (num > 0)
            {
                str = new StringBuilder();
                str.Append(text.Substring(0, num));
            }
            return str.ToString();
        }
        public static string DelLastChar(this StringBuilder str, string strchar)
        {
            string text = str.ToString();
            int num = text.LastIndexOf(strchar);
            if (num > 0)
            {
                str = new StringBuilder();
                str.Append(text.Substring(0, num));
            }
            return str.ToString();
        }
        public static string Remove(this StringBuilder str, int Start, int Num)
        {
            str.Remove(Start, Num);
            return str.ToString();
        }
        public static string AppendSpace(this StringBuilder str, int SpaceNum, string Text)
        {
            str.Append(Space(str,SpaceNum));
            str.Append(Text);
            return str.ToString();
        }
        public static string AppendSpaceLine(this StringBuilder str, int SpaceNum, string Text)
        {
            str.Append(Space(str,SpaceNum));
            str.Append(Text);
            str.Append("\r\n");
            return str.ToString();
        }
        public static string AppendLine(this StringBuilder str)
        {
            str.Append("\r\n");
            return str.ToString();
        }
        public static string AppendLine(this StringBuilder str, string Text)
        {
            str.Append(Text + "\r\n");
            return str.ToString();
        }
    }
}
